﻿using System;
using System.Linq;

class MaximalSequenceOfIncreasingNumbers
{
    static void Main()
    {
        Console.Write("Number of elements of array:");
        int arrayLength = int.Parse(Console.ReadLine());
        int[] array = new int[arrayLength];
        for (int i = 0; i < array.Length; i++)
        {
            Console.Write("\nChar element a[{0}]:", i);
            array[i] = int.Parse(Console.ReadLine());
        }
        //int[] array = { 3, 2, 3, 4, 2, 2, 4 };

        string bestSequence = "";
        int bestNumberRepetition = 1;

        string candidateNumber = "";
        int candidateNumberRepetition = new int();

        for (int i = 0; i < array.Length - 1; i++)
        {
            if (array[i] == array[i + 1] - 1)
            {
                if (candidateNumber == "")
                {
                    candidateNumber = array[i] + "," + array[i + 1];
                    candidateNumberRepetition++; 
                }
                else
                {
                    candidateNumber = candidateNumber + "," + array[i + 1];
                    candidateNumberRepetition++; 
                }
            }
            else
            {
                candidateNumber = "";
                candidateNumberRepetition = 1;
            }
            if (candidateNumberRepetition >= bestNumberRepetition)
            {
                bestSequence = candidateNumber;
                bestNumberRepetition = candidateNumberRepetition;
            }
        }

        Console.WriteLine("Best sequence is: {0}",bestSequence);
    }
}